package com.echo.im.storage.backup.mq;


import cn.hutool.core.bean.BeanUtil;
import com.echo.im.common.vo.message.GroupMessageVO;
import com.echo.im.mq.contant.QueueConstants;
import com.echo.im.mq.event.receiver.AbstractMessageReceiver;
import com.echo.im.repository.dao.entity.GroupMessage;
import com.echo.im.repository.dao.mapper.GroupMessageMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *群聊消息存储队列消费者
 * @author echo
 * @date 2024-08-14
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class GroupStorageMessageReceiver extends AbstractMessageReceiver<GroupMessageVO> {


    private final GroupMessageMapper groupMessageMapper;


    @Override
    public void doReceive(GroupMessageVO data) {
        GroupMessage groupMessage = BeanUtil.copyProperties(data, GroupMessage.class);
        groupMessageMapper.insert(groupMessage);

    }

    @Override
    public String getQueueName() {
        return QueueConstants.STORE_GROUP_QUEUE;
    }
}
